package com.geetour.columbus.region.dao.impl;

import java.util.List;

import com.geetour.columbus.common.exceptions.DAOException;
import com.geetour.columbus.common.model.R.ProvincePage;
import com.geetour.columbus.core.ibatis.SqlMapClientDaoSupportEx;
import com.geetour.columbus.region.dao.IProvincePageDAO;

public class ProvincePageDAOImpl extends SqlMapClientDaoSupportEx implements IProvincePageDAO {

    @Override
    public void insertProvincePage(ProvincePage province) throws DAOException {
        if (province == null || province.getName() == null) {
            return;
        }
        this.insert("insertProvincePage", province);
    }

    @Override
    public int insertProvincePageBatch(List<ProvincePage> list) throws DAOException {
        if (list == null || list.isEmpty()) {
            return -1;
        }
        return this.insert("insertProvincePage", list);
    }

    @Override
    public int updateProvincePageById(ProvincePage province) throws DAOException {
        if (province == null) {
            return -1;
        }
        return this.update("updateProvincePageById", province);
    }

    @Override
    public int deleteProvincePageById(Long id) throws DAOException {
        if (id == null) {
            return -1;
        }
        return this.delete("deleteProvincePageById", id);
    }

    @Override
    public ProvincePage findProvincePageById(Long id) throws DAOException {
        if (id == null) {
            return null;
        }
        return (ProvincePage) this.queryObject("findProvincePageById", id);
    }

    @SuppressWarnings("unchecked")
    @Override
    public List<ProvincePage> findAllProvincePages() throws DAOException {
        return (List<ProvincePage>) this.queryList("findAllProvincePages", null);
    }

    @SuppressWarnings("unchecked")
    @Override
    public List<ProvincePage> findProvincePages(ProvincePage province) throws DAOException {
        if (province == null) {
            return null;
        }
        return (List<ProvincePage>) this.queryList("findProvincePages", province);
    }

}
